package com.xbongbong.pro.enums;

import com.xbongbong.paas.enums.FieldTypeEnum;
import lombok.Getter;

import java.util.Objects;

/**
 * 关联表单可作条件的字段
 * @author: xingxing.xiao
 * @date: 2020/08/03 11:07
 */
@Getter
public enum FieldConditionEnum {

    TEXT(FieldTypeEnum.TEXT),

    TEXTAREA(FieldTypeEnum.TEXTAREA),

    NUM(FieldTypeEnum.NUM),

    DATETIME(FieldTypeEnum.DATETIME),

    RADIO_GROUP(FieldTypeEnum.RADIO_GROUP),

    CHECKBOX_GROUP(FieldTypeEnum.CHECKBOX_GROUP),

    COMBO(FieldTypeEnum.COMBO),

    COMBO_CHECK(FieldTypeEnum.COMBO_CHECK),

    ADDRESS(FieldTypeEnum.ADDRESS),

    USER(FieldTypeEnum.USER),

    USER_GROUP(FieldTypeEnum.USER_GROUP),

    DEPT(FieldTypeEnum.DEPT),

    DEPT_GROUP(FieldTypeEnum.DEPT_GROUP),

    SERIALNO(FieldTypeEnum.SERIALNO),

    LINK_DATA(FieldTypeEnum.LINK_DATA),

    LINK_DATA_MULTI(FieldTypeEnum.LINK_DATA_MULTI),

    LINK_BUSINESS_SINGLE(FieldTypeEnum.LINK_BUSINESS_SINGLE),

    STAGE_THRUSTER(FieldTypeEnum.STAGE_THRUSTER),
    ;

    private FieldTypeEnum fieldTypeEnum;

    FieldConditionEnum(FieldTypeEnum fieldTypeEnum) {
        this.fieldTypeEnum = fieldTypeEnum;
    }

    public static FieldConditionEnum getByCode(Integer fieldType) {
        for (FieldConditionEnum fieldConditionEnum : values()) {
            if (Objects.equals(fieldConditionEnum.getFieldTypeEnum().getType(), fieldType)) {
                return fieldConditionEnum;
            }
        }
        return null;
    }

}
